package com.ljc.api;

import com.ljc.entity.UserFollowing;
import com.ljc.interfaces.UserFollowingApi;
import com.ljc.mapper.UserFollowingMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.List;

@DubboService
public class UserFollowingApiImpl implements UserFollowingApi {
    @Resource
    private UserFollowingMapper userFollowingMapper;

    /**
     * 根据当前用户 id 和 关注对象 id 删除关注关系
     */
    @Override
    public Integer deleteUserFollowing(Long userId, Long followingId) {
        return userFollowingMapper.deleteUserFollowing(userId, followingId);
    }

    /**
     * 新建和该用户的关注关系
     */
    @Override
    public Integer addUserFollowing(UserFollowing userFollowing) {
        return userFollowingMapper.addUserFollowing(userFollowing);
    }

    /**
     * 根据id 获取用户的关注关系
     */
    @Override
    public List<UserFollowing> getUserFollowings(Long userId) {
        return userFollowingMapper.getUserFollowings(userId);
    }

    /**
     * 根据用户id获取该用户的粉丝
     */
    @Override
    public List<UserFollowing> getUserFans(Long userId) {
        return userFollowingMapper.getUserFans(userId);
    }
}
